package com.hanter.android.saf.result;

import android.content.Intent;
import android.os.Parcel;
import android.os.Parcelable;

import androidx.activity.result.IntentSenderRequest;
import androidx.annotation.Nullable;

/**
 * 文件名：IntentSenderRequestResult <br/>
 * 描述：IntentSenderRequest 结果
 * 创建时间：2022/03/22 17:05
 *
 * @author wangmingshuo
 */
public class IntentSenderRequestResult implements Parcelable {

    @Nullable
    private IntentSenderRequest mRequest;
    private int mResultCode;
    @Nullable
    private Intent mData;

    public IntentSenderRequestResult(@Nullable IntentSenderRequest request, int resultCode, @Nullable Intent data) {
        this.mRequest = request;
        this.mResultCode = resultCode;
        this.mData = data;
    }

    @Nullable
    public IntentSenderRequest getRequest() {
        return mRequest;
    }

    public int getResultCode() {
        return mResultCode;
    }

    @Nullable
    public Intent getData() {
        return mData;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(this.mRequest, flags);
        dest.writeInt(this.mResultCode);
        dest.writeParcelable(this.mData, flags);
    }

    public void readFromParcel(Parcel source) {
        this.mRequest = source.readParcelable(IntentSenderRequest.class.getClassLoader());
        this.mResultCode = source.readInt();
        this.mData = source.readParcelable(Intent.class.getClassLoader());
    }

    protected IntentSenderRequestResult(Parcel in) {
        this.mRequest = in.readParcelable(IntentSenderRequest.class.getClassLoader());
        this.mResultCode = in.readInt();
        this.mData = in.readParcelable(Intent.class.getClassLoader());
    }

    public static final Parcelable.Creator<IntentSenderRequestResult> CREATOR = new Parcelable.Creator<IntentSenderRequestResult>() {
        @Override
        public IntentSenderRequestResult createFromParcel(Parcel source) {
            return new IntentSenderRequestResult(source);
        }

        @Override
        public IntentSenderRequestResult[] newArray(int size) {
            return new IntentSenderRequestResult[size];
        }
    };
}
